package com.ele.client.rpc;

import com.ele.model.Answer;
import com.ele.model.AppUser;
import com.ele.model.Section;
import com.ele.model.Word;
import com.ele.shared.AuthException;
import com.ele.shared.DataException;
import com.ele.shared.action.Action;
import com.ele.shared.dto.grid.SectionGridRow;
import com.ele.shared.dto.grid.WordGridRow;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

import java.util.List;
import java.util.Set;

@RemoteServiceRelativePath("ApplicationService")
public interface ApplicationService extends RemoteService {
    // Sample interface method of remote interface
    String getMessage(String msg);

    List<SectionGridRow> getLessonGridData();

    void deleteLessons(Set<Long> set);

    void deleteWords(Set<Long> set);

    List<WordGridRow> getWordGridData();

    Word getWord(Long id);

    Word saveWord(Word word);

    Section getSection(Long id);

    Section saveSection(Section value);

    void attachWords(Set<Long> set, Long sectionId) throws DataException;

    AppUser login(String email, String password) throws DataException;

    AppUser signUp(String email, String password) throws DataException;

    Section getCurrentSection();

    List<Answer> generateAnswer(String questionText);

    boolean checkAnswer(String answer, Long questionId) throws AuthException;

    List<Action> getActionsList(String answer) throws AuthException;

    AppUser getUser();

    /**
     * Utility/Convenience class.
     * Use ApplicationService.App.getInstance() to access static instance of ApplicationServiceAsync
     */
    public static class App {
        private static ApplicationServiceAsync ourInstance = GWT.create(ApplicationService.class);

        public static synchronized ApplicationServiceAsync getInstance() {
            return ourInstance;
        }
    }
}
